package cn.wolfcode.rbac.web.controller;


import cn.wolfcode.rbac.domain.Permission;
import cn.wolfcode.rbac.query.QueryObject;
import cn.wolfcode.rbac.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("permission")
public class PermissionController {
    @Autowired
    private IPermissionService permissionService;


    @RequestMapping("/list")
    public String list(QueryObject queryObject, Model model) {
        model.addAttribute("result", permissionService.query(queryObject));
        return "permission/list";
    }

    @RequestMapping("delete")
    public String delete(long id) {
        permissionService.delete(id);
        return "redirect:/permission/list";
    }

    @RequestMapping("reload")
    public String reload() {
        permissionService.reload();
        return "redirect:/permission/list";
    }
}
